
import * as PIXI from 'pixi.js';

import amethystBoxSrc from 'common/asset/img/items/amethystBox.png';
import amethystBtnSrc from 'common/asset/img/game/submit.png';
import injectStore from 'components/injectStore';
import Text from 'components/text';
import Rect from 'components/rect';
import Image from 'components/image';
const { Container } = PIXI;

@injectStore
export default class AmethystBoxModal {
  constructor({parent, store, onGetItem, ...props}) {


    const {height, top, width} = props;
    this.onGetItem = onGetItem;
    this.parent = parent;
    this.store = store;
    this.container = new Container();

    let img = new Image({src: amethystBoxSrc, height: 250, top: 120, isAdapt: true});
    img.x = (width - img.width) / 2;

    let getText = new Text({value: '【打开的铁宝箱,里面装着三支防晒乳】', top: 410, fontSize: 34, fontWeight: 600});
    getText.x = (width - getText.width) / 2;

    let useText = new Text({value: '"只有一直是真的,是哪只呢?"试试能辨别真假\n的紫水晶球吧', top: 460, fontSize: 28});
    useText.x = (width - useText.width) / 2;

    let btn = new Rect({top: window.CFG.view.height - 170, left: 0, width: 126, height: 126});

    this.container.addChild(img);
    this.container.addChild(getText);
    this.container.addChild(useText);
    this.container.addChild(btn);


    this.container.y = top;
    this.container.x = (window.CFG.view.width - width) / 2;

    btn.interactive = true;
    btn.on('tap', (e) => {
      e.stopped = true;
      store.useItem('amethyst');
      onGetItem();
      this.parent.container.removeChild(this.container);

    });

  }
}
